﻿using Prism.Commands;
using Prism.Mvvm;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ModuleB.ViewModels
{
    internal class ViewCViewModel : IDialogAware
    {
        public ViewCViewModel()
        {
            ConfireCommand = new DelegateCommand(ConfireCommandFunc);
            CancelCommand = new DelegateCommand(CancelCommandFunc);
        }
        private void CancelCommandFunc() {
            RequestClose?.Invoke( new DialogResult(ButtonResult.No));
        }
        private void ConfireCommandFunc() {
            DialogParameters paras=new DialogParameters();
            paras.Add("Id","1001");
            RequestClose?.Invoke( new DialogResult(ButtonResult.Yes, paras));

        }
        public DelegateCommand ConfireCommand { get; set; }
        public DelegateCommand CancelCommand { get; set; }

      
        public string Title { get; set; } = "标题";

        public event Action<IDialogResult> RequestClose;

        public bool CanCloseDialog()
        {
            return true;
        }

        public void OnDialogClosed()
        {
          
        }

        public void OnDialogOpened(IDialogParameters parameters)
        {
            if (parameters.ContainsKey("Title")) {
                Title = parameters.GetValue<string>("Title");
            }
        }
    }
}
